package se.sll.itintegration.catalogue.mek;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.xml.xpath.XPathExpressionException;
import lombok.extern.slf4j.Slf4j;
import se.sll.itintegration.catalogue.mek.ejb.MekEjb;

/**
 *
 * @author khaleddaham
 */
@Path("/mek")
@Slf4j
public class MekService {
    
    @Inject
    MekEjb mekEjb;

    @GET
    @Path("/kombika/{param}")
    @Produces("application/json")
    public MekData getHsaID(@PathParam("param") String kombika) throws XPathExpressionException {
        log.info("Calling getHsaID.");
        String hsaId = mekEjb.getHsaID(kombika);
        String result = "hsaid: " + hsaId;
        MekData mk = new MekData(kombika, hsaId, "");
        return mk;
    }
    
    @GET
    @Path("/hsa/{param}")
    @Produces("application/json")
    public MekData getKombika(@PathParam("param") String hsaId) throws XPathExpressionException {
        log.info("Calling getKombika.");
        String kombika = mekEjb.getKombika(hsaId);
        String result = "kombika: " + kombika;
        MekData mk = new MekData(kombika, hsaId, "");
        return mk;
    }
    
    @GET
    @Path("/skl/{param}")
    public Response getSKL(@PathParam("param") String hsaId) {
        String result = "";
        return Response.status(200).entity(result).build();
    }
}